package com.example.cinema.entity.service.impl;

import com.example.cinema.entity.MovieReview;
import com.example.cinema.entity.Result;
import com.example.cinema.mapper.MovieMapper;
import com.example.cinema.mapper.MovieReviewMapper;
import com.example.cinema.entity.service.IMovieReviewService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yc138
 * @since 2024-08-26
 */
@Service
public class MovieReviewServiceImpl extends ServiceImpl<MovieReviewMapper, MovieReview> implements IMovieReviewService {
    @Autowired
    MovieReviewMapper movieReviewMapper;
    //新增评论
    @Override
    public Result addMovieReview(MovieReview movieReview) {
        if (movieReview.getReviewContent()==null||movieReview.getReviewContent().isBlank()==true){
            return new Result(-1,"内容不能为空",null);
        }
        try{
            movieReviewMapper.insert(movieReview);
            return new Result(1,"评论成功",null);
        }catch (Exception e){
            return  new Result(-1,"评论失败",null);
        }
    }
}
